from django.db import models


# Create your models here.
# from user.models import User
#

class Department(models.Model):
    title = models.CharField('部门名称', max_length=50,null=True)
    master = models.ForeignKey('user.User', max_length=30,on_delete=models.SET_NULL,null=True)
    dep_info = models.TextField('部门信息',max_length=1024,null=True)
    dep_path = models.CharField('部门路径',max_length=30 ,null=True)
    parent = models.ForeignKey('self', on_delete=models.SET_NULL,null=True)
    creator = models.ForeignKey('user.User',on_delete=models.SET_NULL,null=True,related_name="user1")
    created_time = models.DateTimeField('创建时间',auto_now_add=True,null=True)
    updated_time = models.DateTimeField('修改时间',auto_now=True,null=True)

    def __str__(self):
        return f'部门名称:{self.title},部门负责人:{self.master}'

    class Meta:
        db_table = 'department'